import { ElMessage } from "element-plus";

interface MessageOption {
  type: "success" | "warning" | "info" | "error";
  message: string;
  duration: number;
  showClose?: boolean;
  center?: boolean;
  onClose?: () => void;
}

export const message = (option: MessageOption) => {
  return ElMessage(option);
};

// import Message from "@/components/Message.vue";
// import { createApp } from "vue";

// interface MessageOptions {
//   message: string;
//   type: "success" | "info" | "warning" | "error";
//   duration: number;
// }

// export const message = (option: MessageOptions) => {
//   const div = document.createElement("div");
//   div.classList.add("message");
//   div.id = `message${Date.now()}`;
//   document.body.appendChild(div);
//   const msg = createApp(Message, {
//     duration: option.duration,
//     message: option.message,
//     type: option.type,
//   });
//   msg.mount(div);
//   setTimeout(() => {
//     msg.unmount();
//     document.body.removeChild(div);
//   }, option.duration);
// };
